package com.jrzh.db.migration.sys;

import com.eroi.migrate.Define;
import com.eroi.migrate.Define.DataTypes;
import com.jrzh.framework.migration.BaseMigration;
import com.jrzh.framework.migration.MigrationHelper;
/**
 * 增加系统用户表，角色用户中间表
 * @author Mr.Shower
 *
 */
public class Migration_3 extends BaseMigration{
	
	private static final String TABLE_NAME = "sys_users";
	private static final String MID_TABLE_NAME = "sys_users_roles";
	
	@Override
	public void down() {
		log.info("##########回滚Sys模块 Migration_3##########");
		MigrationHelper.dropTable(TABLE_NAME);
		MigrationHelper.dropTable(MID_TABLE_NAME);
	}

	@Override
	public void up() {
		log.info("##########执行Sys模块 Migration_3##########Begin");
		table(TABLE_NAME, "系统用户表", true,
				pk(),
				column("_code", "编号", Define.DataTypes.VARCHAR, Define.length(128)),
				column("_name", "名称", DataTypes.VARCHAR, Define.length(256)),
				column("_password", "密码", DataTypes.VARCHAR, Define.length(256)),
				column("_salt", "盐值", DataTypes.VARCHAR, Define.length(16)),
				column("_sex", "性别", DataTypes.TINYINT),
				column("_card_id", "身份证", DataTypes.VARCHAR, Define.length(64)),
				column("_tel", "电话", DataTypes.VARCHAR, Define.length(32)),
				column("_address", "地址", DataTypes.VARCHAR, Define.length(256)),
				column("_email", "邮箱", DataTypes.VARCHAR, Define.length(32)),
				column("_remark", "备注", DataTypes.VARCHAR, Define.length(512))
		);
		table(MID_TABLE_NAME, "角色用户中间表", false,
				column("_user_id", "用户ID", Define.DataTypes.CHAR, Define.length(36)),
				column("_role_id", "角色ID", DataTypes.CHAR, Define.length(36)));
		log.info("##########执行Sys模块 Migration_3##########End");
	}

}
